[#assign name_code = "VIEW-DEIT" /]

[#assign entityType = "dto" /]

<div id="dlg-${name_code}" class="main-content">
[#if viewEditType == '1' && orderEntitys?? && (orderEntitys[entityType]?size>0) ]
  <div class="row">&nbsp;</div>
  <div class="row padding-right"> 
    [@commomEle1 parent="" vlist=orderEntitys[entityType] viewEditType=viewEditType/]
  </div> 
  <div class="row">&nbsp;</div>
[#elseif viewEditType == '3' && orderEntitys?? && (orderEntitys[entityType]?size>0) ]
[#assign entityVO = groupNames[entityType] /]
[#assign entityVO2 = groupEntitys[entityType] /]
  <div class="overflow-n" style="display: flex;display: -webkit-flex;flex-direction: column;">
    <nav id="scroll-${name_code}" class="navbar navbar-default" style="margin: unset;">
      <div class="container-fluid">
        <div class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            [#if entityVO?exists]
            [#list entityVO?keys as key]
            <li [#if key_index ==0]class="active"[/#if]><a href="#${name_code+'-'+key}">${entityVO[key]!'默认'}</a></li>
            [/#list]
            [/#if]
          </ul>
        </div>
      </div>
    </nav>
    <div id="scroll-conten-${name_code}" class="overflow-y">
      [#if entityVO?exists]
      [#list entityVO?keys as key]
      <div id="${name_code + '-'+key}"  style="min-height:600px;">
        <div class="row">&nbsp;</div>
        <div class="row"> 
        <div class="col-sm-12">
          <fieldset> 
            <legend class="text-info">${entityVO[key]}</legend>
          </fieldset>
        </div>
        </div>
        <div class="row">&nbsp;</div>
        <div class="row padding-right">
          [@commomEle1 parent="" vlist=entityVO2[key] viewEditType=viewEditType/]
        </div> 
        <div class="row">&nbsp;</div>
      </div>
      [/#list]
      [/#if]
    </div>
  </div>
[#elseif viewEditType == '2' && orderEntitys?? && (orderEntitys[entityType]?size>0) ]
[#assign entityVO = groupNames[entityType] /]
[#assign entityVO2 = groupEntitys[entityType] /]
  <ul id="tab-${name_code}" class="nav nav-tabs">
    [#if entityVO?exists]
    [#list entityVO?keys as key]
    <li [#if key_index ==0]class="active"[/#if] ><a href="#${name_code + '-'+key}" data-toggle="tab">${entityVO[key]!'默认'}</a></li>
    [/#list]
    [/#if]
  </ul>
  <div id="tabContent-${name_code}" class="tab-content">
    [#if entityVO?exists]
    [#list entityVO?keys as key]
    <div id="${name_code + '-'+key}" class="tab-pane fade[#if key_index ==0] in active[/#if]">
      <div class="row">&nbsp;</div>
      <div class="row padding-right">
      [@commomEle1 parent="" vlist=entityVO2[key] viewEditType=viewEditType/]
      </div> 
      <div class="row">&nbsp;</div>
    </div>
    [/#list]
    [/#if]
  </div>
  
[#elseif viewEditType == '4' && orderEntitys?? && (orderEntitys[entityType]?size>0) ]
   [@commomEle1 parent="" vlist=orderEntitys[entityType] viewEditType=viewEditType/]
[/#if]
</div>

<script>

function initTemplateViewEdit(el){

[@commomInit1 vlist=orderEntitys[entityType]  viewEditType=viewEditType/]

$('#scroll-conten-${name_code}').scrollspy({ target: '#scroll-${name_code}' });

}

</script>

[#--  初始化元素 --]
[#macro commomEle1 parent vlist viewEditType]
[#if vlist?? && (vlist?size>0)]
    [#if viewEditType=="4"]
    <table id="tbl-query-${name_code}"><table>
    [#else]
    [#list vlist as b]
    [#if b.fieldType=="2"]
    [#if b.children?? && b.children?size>0]
    [@commomEle1 parent=b.fieldJavaCode vlist=b.children viewEditType=viewEditType/]
    [/#if]
    [#else]
    <div cpt-id="${b._uniqueId}" [#if parent!=""]datalevel="${parent}"[/#if] class="col-xs-[#if b.gridClonums??]${b.gridClonums}[#else]6[/#if] col-sm-[#if b.gridClonums??]${b.gridClonums}[#else]6[/#if][#if b.pageShowFlag=='0'] hidden[/#if]">
      [#if viewEditType=="1" || b.componentType!="table"]
      <label class="form-lable">${b.fieldTitle}</label>
      <div class="input-block">
        [#if b.componentType=="input"]
        <input id="${b.fieldJavaCode}" name="${b.fieldJavaCode}" data-options="{[#if (b.mustFlag!"0")=="1"]required:true[/#if]}" style="width:100%;" />
        [#elseif b.componentType=="text"]
        <input id="${b.fieldJavaCode}" name="${b.fieldJavaCode}" data-options="{[#if (b.mustFlag!"0")=="1"]required:true[/#if]}" style="width:100%;" />
        [#elseif b.componentType=="select"]
        <select id="${b.fieldJavaCode}" name="${b.fieldJavaCode}" data-options="{[#if (b.mustFlag!"0")=="1"]required:true[/#if]}" style="width:100%;" ></select>
        [#elseif b.componentType=="grid"]
        <input id="${b.fieldJavaCode}" name="${b.fieldJavaCode}" data-options="{[#if (b.mustFlag!"0")=="1"]required:true[/#if]}" style="width:100%;" />
        [#elseif b.componentType=="label"]
        <label id="${b.fieldJavaCode}" name="${b.fieldJavaCode}" data-options="{[#if (b.mustFlag!"0")=="1"]required:true[/#if]}" style="width:100%;" ></label>
        [#elseif b.componentType=="checkbox"]
        <span class="textbox textbox2 easyui-fluid"><div class="input-g"><input id="${b.fieldJavaCode}" name="${b.fieldJavaCode}" data-options="{[#if (b.mustFlag!"0")=="1"]required:true[/#if]}" style="" /></div></span>
        [#elseif b.componentType=="radiobox"]
        <span class="textbox textbox2 easyui-fluid"><div class="input-g"><input id="${b.fieldJavaCode}" name="${b.fieldJavaCode}" data-options="{[#if (b.mustFlag!"0")=="1"]required:true[/#if]}" style="" /></div></span>
        [#elseif b.componentType=="selecttree"]
        <input id="${b.fieldJavaCode}" name="${b.fieldJavaCode}" data-options="{[#if (b.mustFlag!"0")=="1"]required:true[/#if]}" style="" />
        [#elseif b.componentType=="table"]
        <div style="border: 1px solid #EEE;"><table id="${b.fieldJavaCode}" name="${b.fieldJavaCode}" listlevel="${b.fieldJavaCode}" style="min-height:300px;"></table></div>
        [#else]

        [/#if]
      </div>
      [#else]
        <div style="border: 1px solid #EEE;"><table id="${b.fieldJavaCode}" name="${b.fieldJavaCode}" listlevel="${b.fieldJavaCode}" style="min-height:300px;"></table></div>
      [/#if]
    </div>
    [/#if]
    [/#list]
    [/#if]
[/#if]
    
[/#macro]


[#--  初始化组件 --]
[#macro commomInit1 vlist viewEditType]
[#if vlist?? && (vlist?size>0)]
[#if viewEditType=="4"]
    var buttonsIdx = [4];
    var buttonsFunc = [];
    var options = {
                data : [],
                columns:[[
                [#list vlist as b]
                [#if b.fieldUseType=="1" || b.fieldUseType=="2" ]
                {field: '${b.fieldJavaCode}', title: '${b.fieldTitle}', align: 'center', width: 100 [#if b.inputType=="easy-select"|| b.inputType=="easy-selectx" || b.inputType=="easy-grid"], formatter: function(value,rowData,rowIndex){ return value; }[/#if] },
                [/#if]
                [/#list]
                ]],
    };
    zUtil.tableInit('${'#tbl-query-'+name_code}',options,buttonsIdx,buttonsFunc);
[#else]
[#list vlist as b]
[#if b.fieldUseType=="1" || b.fieldUseType=="2" ]
[#if b.fieldType=="2"]
    [#if b.children?? && b.children?size>0]
    [@commomInit1 vlist=b.children viewEditType=viewEditType/]
    [/#if]
[#elseif b.componentType=="input"]
zUtil.inputInit('#dlg-${name_code} #${b.fieldJavaCode}','input',
${b.inputOptions2!'{}'}
);
[#if (b.readonlyFlag!'0')=="1"]zUtil.readonly('#dlg-${name_code} #${b.fieldJavaCode}');[/#if]
[#elseif b.componentType=="text"]
zUtil.inputInit('#dlg-${name_code} #${b.fieldJavaCode}','input',
${b.inputOptions2!'{multiline:true}'}
);
[#if (b.readonlyFlag!'0')=="1"]zUtil.readonly('#dlg-${name_code} #${b.fieldJavaCode}');[/#if]
[#elseif b.componentType=="select"]
zUtil.inputInit('#dlg-${name_code} #${b.fieldJavaCode}','select',
${b.inputOptions2!'{}'}
);
[#if (b.readonlyFlag!'0')=="1"]zUtil.readonly('#dlg-${name_code} #${b.fieldJavaCode}');[/#if]
[#elseif b.componentType=="grid"]
zUtil.inputInit('#dlg-${name_code} #${b.fieldJavaCode}','cgrid',
${b.inputOptions2!'{}'}
);
[#if (b.readonlyFlag!'0')=="1"]zUtil.readonly('#dlg-${name_code} #${b.fieldJavaCode}');[/#if]
[#elseif b.componentType=="table"]
zUtil.tableInit('#dlg-${name_code} #${b.fieldJavaCode}',
{
[#if b.children?? && b.children?size>0]
[#assign entityChildDTO = b['children'] /]
columns:[[
            [#list entityChildDTO as b]
            {field: '${b.fieldJavaCode}', title: '${b.fieldTitle}', align: 'center', width: 100 [#if b.inputType=="easy-select"|| b.inputType=="easy-selectx" || b.inputType=="easy-grid"], formatter: function(value,rowData,rowIndex){ return value; }[/#if] },
            [/#list]
        ]],
[/#if]
},[0]
);
[#if (b.readonlyFlag!'0')=="1"]zUtil.readonly('#dlg-${name_code} #${b.fieldJavaCode}');[/#if]
[#elseif b.componentType=="selecttree"]
zUtil.inputInit('#dlg-${name_code} #${b.fieldJavaCode}','input',
${b.inputOptions2!'{}'}
);
[#if (b.readonlyFlag!'0')=="1"]zUtil.readonly('#dlg-${name_code} #${b.fieldJavaCode}');[/#if]
[#elseif b.componentType=="checkbox"]
zUtil.inputInit('#dlg-${name_code} #${b.fieldJavaCode}','check',
${b.inputOptions2!'{}'}
);
[#if (b.readonlyFlag!'0')=="1"]zUtil.readonly('#dlg-${name_code} #${b.fieldJavaCode}');[/#if]
[#elseif b.componentType=="radiobox"]
zUtil.inputInit('#dlg-${name_code} #${b.fieldJavaCode}','radio',
${b.inputOptions2!'{}'}
);
[#if (b.readonlyFlag!'0')=="1"]zUtil.readonly('#dlg-${name_code} #${b.fieldJavaCode}');[/#if]
[#elseif b.componentType=="label"]
[/#if]
[/#if]
[/#list]
[/#if]
[/#if]
[/#macro]


